﻿using MovingChame.WindowsStoreApp.Helpers;
using MovingChameLibrary.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace MovingChame.WindowsStoreApp.Converters
{
    public class ImageModelToBitmapImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ImageModel imageModel = value as ImageModel;
            if (imageModel.ImageType == ImageType.LocalImage)
                return string.Format("{0}{1}", WinStoreConstants.baseUri, imageModel.ImagePath);
            else
                return ImageHelper.ConvertByteArrayToImage(imageModel.ImageStream);
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}